export default {
	// 获取页面数据
	getTableData() {
		var params = {
			// type:0,
			language: this.$store.getters.getLanguage,
			// page: this.$refs.Page.pagination.current,
			// limit: this.$refs.Page.pagination.pageSize
		}

		this.axiosGets("MainIndex/areaList", params, function(res) {

			this.tableData = res.data.data
			//分页
			// this.total = res.data.data.total
			// console.log(this.total);
		})
	},

	

	//编辑
	edit(scope) {
		this.$refs.Edit.form.id = scope.id;
		this.$refs.Edit.form.title = scope.title;
		// this.$refs.Edit.form.img_id = scope.img_id;
		this.$refs.Edit.form.url = scope.url;
		this.$refs.Edit.form.sort = scope.sort;
		// this.$refs.Edit.form.language = scope.language;
		this.$refs.Edit.form.text1 = scope.text1;
		this.$refs.Edit.form.text2 = scope.text2;
		this.$refs.Edit.form.text3 = scope.text3;
		this.$refs.Edit.form.text4 = scope.text4;
		
		if(scope.file){
			this.$refs.Edit.upImg.imageUrl = this.imgURL + scope.file.url+'/'+scope.file.name;
		}
		// this.$refs.Edit.imageUrl = this.imgURL + scope.img_url;

		this.$refs.Edit.isShow = true;
	},
	
	
	stop(scope){
		let params = {
			id:scope.id,
			language: this.$store.getters.getLanguage,
			status:scope.status == 0 ? 1 : 0
		}
		
		this.axiosGets("MainIndex/areaStatus", params, function(res) {
		
			if(res.data.code == 0 ) {
				this.msgSuccess(res.data.message)
				this.getTableData();
			}else {
				this.msgError(res.data.message)
			}
		})
	},
	

	//删除
	remove(scope) {
		if(scope.status) {
			this.$confirm('此操作将打开此数据在前台展示, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.stop(scope);
				// this.sureRemove(scope.banner_id);
			}).catch(() => {
				this.$message({
					type: 'info',
					message: '已取消删除'
				});
			});
		}else {
		
			this.$confirm('此操作将关闭此数据在前台展示, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.stop(scope);
				// this.sureRemove(scope.banner_id);
			}).catch(() => {
				this.$message({
					type: 'info',
					message: '已取消删除'
				});
			});
			
		}
	},

	//确定删除
	sureRemove(id) {

		this.axiosGets("index/homepage/banner_delete?banner_id=" + id, {}, function(res) {
			if (res.data.code === 0) {
				this.getTableData();
				this.msgSuccess(res.data.msg)
			} else {
				this.msgError(res.data.msg)
			}
		})
	}
}
